using System;
using System.Collections.Generic;
using System.Text;

namespace My.IdlConverter.Core.Types
{
    public class TypeFormatter : ITypeFormatter
    {
        private IType _consumer;
        private ITypeFormatStrategy _formatStrategy;

        public TypeFormatter()
        {
        }

        public TypeFormatter(IType consumer,ITypeFormatStrategy formatStrategy)
        {
            _consumer = consumer;
            _formatStrategy = formatStrategy;
        }

        public ITypeFormatStrategy FormatStrategy
        {
            get
            {
                return _formatStrategy;
            }
            set
            {
                _formatStrategy = value;
            }
        }

        public IType Consumer
        {
            get
            {
                return _consumer;
            }
            set
            {
                _consumer = value;
            }
        }

        public virtual string Format()
        {
            if (FormatStrategy == null || Consumer == null)
                throw new NullReferenceException("The consumer should not be empty.");

            return FormatStrategy.Format(Consumer);
        }
    }
}
